<?php
/**
 * Magento Enterprise Edition
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Magento Enterprise Edition End User License Agreement
 * that is bundled with this package in the file LICENSE_EE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.magento.com/license/enterprise-edition
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     default_default
 * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
 * @license http://www.magento.com/license/enterprise-edition
 */
?>

<?php if ($this->canDisplayGiftWrappingForItems()): ?>
<div id="wrapping-item-container" class="no-display">
    <h4>Gift Wrapping</h4>
    <div class="gift-wrapping-form">
        <div class="gift-wrapping-design">
            <img class="image-box no-display" id="item-image-box" height="75" width="75" alt="" src=""/>
            <?php echo $this->__('Gift Wrapping Design') ?>: <span id="item-design"></span>
            <div id="item-price-box" class="no-display">
            <?php if ($this->getDisplayWrappingBothPrices()): ?>
            <div>
                <span class="label"><?php echo $this->__('Price Excl. Tax') ?>:</span>
                <span class="price" id="item-price-excl-tax"></span>
            </div>
            <div>
                <span class="label"><?php echo $this->__('Price Incl. Tax') ?>:</span>
                <span class="price" id="item-price-incl-tax"></span>
            </div>
            <?php else: ?>
            <div>
                <span class="label"><?php echo $this->__('Price') ?>:</span>
                <span class="price" id="item-price"></span>
            </div>
            <?php endif; ?>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
//<![CDATA[
var giftWrappingItem = {
    itemsInfo : <?php echo $this->getItemsInfo()->toJson() ?>,
    designsInfo : <?php echo $this->getDesignsInfo()->toJson() ?>,
    init : function() {
        $$('.action-link').each(function (el) {
            Event.observe(el, 'click', this.setData.bind(this));
        }, this);
    },
    setData : function(event){
        var element = Event.element(event).id;
        var id = element.sub('gift_options_link_','');
        var value = this.itemsInfo[id].design;

        if (value) {
            $('wrapping-item-container').removeClassName('no-display');
        } else {
            $('wrapping-item-container').addClassName('no-display');
        }
        if (this.itemsInfo[id]) {
            if (this.itemsInfo[id].price_incl_tax) {
                $('item-price-incl-tax').update(this.itemsInfo[id].price_incl_tax);
            }
            if (this.itemsInfo[id].price_excl_tax) {
                $('item-price-excl-tax').update(this.itemsInfo[id].price_excl_tax);
            }
            if (this.itemsInfo[id].price) {
                $('item-price').update(this.itemsInfo[id].price);
            }
            $('item-price-box').removeClassName('no-display');
        }
        if (this.designsInfo[value]) {
            if (this.designsInfo[value].path) {
                $('item-image-box').src = this.designsInfo[value].path;
                $('item-image-box').removeClassName('no-display');
            }
            if (this.designsInfo[value].design) {
                $('item-design').update(this.designsInfo[value].design);
            }
        }
        Event.stop(event);
    }
}
giftWrappingItem.init();
//]]>
</script>
<?php endif; ?>
